package cn.itsource.article.service.impl;

import cn.itsource.article.domain.Comment;
import cn.itsource.article.mapper.CommentRepository;
import cn.itsource.article.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentRepository commentRepository;

    @Override
    public void selectComment(Comment comment) {
        comment.setUserId(1L);
        comment.setNickname("奥尔格");
        commentRepository.save(comment);
    }

    @Override
    public List<Comment> selectCommentId(Long articleId) {
        return commentRepository.findByArticleId(articleId);
    }

    @Override
    public void deleteCommentId(String id) {
        commentRepository.deleteById(id);
    }


}
